function [out] = graphing (DATA,channels_to_avg,condition_names,title_name,var_start,var_end,sampling_rate)

    condition_1_avg = 0;
    condition_2_avg = 0;
    condition_3_avg = 0;
    condition_4_avg = 0;

    for i = 1 : length (DATA) ; condition_1_avg = DATA{i,1} + condition_1_avg;end
    for i = 1 : length (DATA) ; condition_2_avg = DATA{i,2} + condition_2_avg;end
    for i = 1 : length (DATA) ; condition_3_avg = DATA{i,3} + condition_3_avg;end
    for i = 1 : length (DATA) ; condition_4_avg = DATA{i,4} + condition_4_avg;end
    
    condition_1_avg =  condition_1_avg/length (DATA);
    condition_2_avg =  condition_2_avg/length (DATA);
    condition_3_avg =  condition_3_avg/length (DATA);
    condition_4_avg =  condition_4_avg/length (DATA);
    
    condition_1_channel_avg = 0;
    condition_2_channel_avg = 0;
    condition_3_channel_avg = 0;
    condition_4_channel_avg = 0;
    
    for i = 1 : length (channels_to_avg) ; condition_1_channel_avg = condition_1_avg(channels_to_avg(1,i),:) + condition_1_channel_avg;end
    for i = 1 : length (channels_to_avg) ; condition_2_channel_avg = condition_2_avg(channels_to_avg(1,i),:) + condition_2_channel_avg;end
    for i = 1 : length (channels_to_avg) ; condition_3_channel_avg = condition_3_avg(channels_to_avg(1,i),:) + condition_3_channel_avg;end
    for i = 1 : length (channels_to_avg) ; condition_4_channel_avg = condition_4_avg(channels_to_avg(1,i),:) + condition_4_channel_avg;end   
    
    condition_1_channel_avg=condition_1_channel_avg/length(channels_to_avg);
    condition_2_channel_avg=condition_2_channel_avg/length(channels_to_avg);
    condition_3_channel_avg=condition_3_channel_avg/length(channels_to_avg);
    condition_4_channel_avg=condition_4_channel_avg/length(channels_to_avg);
    
    numn = -99.99;
    for counter = 1 : 141 ; timeline (1,counter) = numn + 7.8014*(counter-1); end
    
    maxfig=max(horzcat(condition_1_channel_avg,condition_2_channel_avg,condition_3_channel_avg,condition_4_channel_avg));
    minfig=min(horzcat(condition_1_channel_avg,condition_2_channel_avg,condition_3_channel_avg,condition_4_channel_avg));
    
    figure;
    plot(timeline,condition_1_channel_avg, 'Color','black','LineWidth',1.5);
    hold on;
    plot(timeline,condition_2_channel_avg, 'Color','blue','LineWidth',1.5);
    plot(timeline,condition_3_channel_avg, 'Color','green','LineWidth',1.5);
    plot(timeline,condition_4_channel_avg, 'Color','red','LineWidth',1.5);
    plot(-200:1000,0,':','Color','black')
    plot(0,minfig-0.5:0.01:maxfig+0.5,'-','Color','black')
    set(gca, 'FontName', 'Times new roman')
    set(gca, 'FontSize', 16)
    xlabel('Time (ms)'                     );
    ylabel('Amplitude    [micro V]'                      );
    legend('hide')
    axis([-100,1000, minfig-0.5,maxfig+0.5])

    
    hold off;
    
    extra_graphs = menu('Would you like to print out extra graphs ?','yes - (1-2 & 3-4)','yes - (1-3 & 2-4)','yes - (AVG(1&2) - AVG(3&4)','yes - (AVG(1&3) - AVG(2&4)', 'yes - (AVG(1&4) - AVG(2&3)', 'yes - use log','no');  
    
    if extra_graphs == 1            
           temp1=condition_1_channel_avg-condition_2_channel_avg;
           temp2=condition_3_channel_avg-condition_4_channel_avg;
            
           figure;
           plot(timeline,temp1, 'Color','black','LineWidth',1.5);
           hold on;
           plot(timeline,temp2, 'Color','blue','LineWidth',1.5);
           
           plot(-200:1000,0,':','Color','black');
           plot(0,minfig-0.5:0.01:maxfig+0.5,'-','Color','black');
           set(gca, 'FontName', 'Times new roman')
           set(gca, 'FontSize', 16)
            xlabel('Time (ms)'                     );
            ylabel('Amplitude    [micro V]'                      );
            legend('hide')
            axis([-100,1000, minfig-0.5,maxfig+0.5])

            hold off;
            
    elseif extra_graphs == 2         

           temp1=condition_1_channel_avg-condition_3_channel_avg;
           temp2=condition_2_channel_avg-condition_4_channel_avg;
            
           figure;
           plot(timeline,temp1, 'Color','black','LineWidth',1.5);
           hold on;
           plot(timeline,temp2, 'Color','blue','LineWidth',1.5);
       
           
           plot(-200:1000,0,':','Color','black');
           plot(0,minfig-0.5:0.01:maxfig+0.5,'-','Color','black');
           set(gca, 'FontName', 'Times new roman')
           set(gca, 'FontSize', 16)
           xlabel('Time (ms)'                     );
           ylabel('Amplitude    [micro V]'                      );
           legend('hide')
           axis([-100,1000, minfig-0.5,maxfig+0.5])
    
           hold off;        
        
    elseif extra_graphs == 3         


           temp1=(condition_1_channel_avg+condition_2_channel_avg)/2;
           temp2=(condition_3_channel_avg+condition_4_channel_avg)/2;
            
           figure;
           plot(timeline,temp1, 'Color','black','LineWidth',1.5);
           hold on;
           plot(timeline,temp2, 'Color','blue','LineWidth',1.5);
       
            
           plot(-200:1000,0,':','Color','black');
           plot(0,minfig-0.5:0.01:maxfig+0.5,'-','Color','black');
           set(gca, 'FontName', 'Times new roman')
           set(gca, 'FontSize', 16)
           xlabel('Time (ms)'                     );
           ylabel('Amplitude    [micro V]'                      );
           legend('hide')
           axis([-100,1000, minfig-0.5,maxfig+0.5])
    
           hold off;
           
    elseif extra_graphs == 4         


           temp1=(condition_1_channel_avg+condition_3_channel_avg)/2;
           temp2=(condition_2_channel_avg+condition_4_channel_avg)/2;
            
           figure;
           plot(timeline,temp1, 'Color','black','LineWidth',1.5);
           hold on;
           plot(timeline,temp2, 'Color','blue','LineWidth',1.5);
                  
           
           plot(-200:1000,0,':','Color','black');
           plot(0,minfig-0.5:0.01:maxfig+0.5,'-','Color','black');
           set(gca, 'FontName', 'Times new roman')
           set(gca, 'FontSize', 16)
           xlabel('Time (ms)'                     );
           ylabel('Amplitude    [micro V]'                      );
           legend('hide')
          axis([-100,1000, minfig-0.5,maxfig+0.5])
      
           hold off;
           
    elseif extra_graphs == 5         


           temp1=(condition_1_channel_avg+condition_4_channel_avg)/2;
           temp2=(condition_2_channel_avg+condition_4_channel_avg)/2;
            
           figure;
           plot(timeline,temp1, 'Color','black','LineWidth',1.5);
           hold on;
           plot(timeline,temp2, 'Color','blue','LineWidth',1.5);
                  
           
           plot(-200:1000,0,':','Color','black');
           plot(0,minfig-0.5:0.01:maxfig+0.5,'-','Color','black');
           set(gca, 'FontName', 'Times new roman')
           set(gca, 'FontSize', 16)
           xlabel('Time (ms)'                     );
           ylabel('Amplitude    [micro V]'                      );
           legend('hide')
          axis([-100,1000, minfig-0.5,maxfig+0.5])
      
           hold off;           
           
    end
            
    
    gf{1,2} = 'fffff';
    
    legend(char(condition_names{1,1}),char(condition_names{2,1}),char(condition_names{3,1}),char(condition_names{4,1}));
    fig_title = strcat(char(title_name), '____',num2str(   round (var_start/(sampling_rate/1000))-100    ),'____',num2str(      round (var_end/(sampling_rate/1000))-100    ) );
    title(fig_title);
    
    out =1;
    

end